#include "ProcessIteratorWin.h"

ProcessIteratorWin::ProcessIteratorWin() : th32handle(share_handle(CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0))), first(true)
{
	PROCESSENTRY32 info = {};
	info.dwSize = sizeof(info);
	if (::Process32First(th32handle.get(), &info))
	{
		HANDLE yohandle = ::OpenProcess(PROCESS_ALL_ACCESS, 0, info.th32ProcessID);
		if (yohandle)
		{
			proc = ProcessWin::fromHandleAndName(share_handle(yohandle), info.szExeFile);
		}
	}
}

